package cc.autoapi.pucong.auto.flow.core.qlexpress.entity;

import cc.autoapi.pucong.auto.flow.core.qlexpress.builder.FlowLogicBuilder;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.CompareTypeEnum;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.ComputerTypeEnum;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.NodeTypeEnum;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.QlValueTypeEnum;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 实体属性
 */
@Data
public class EntityValueNode extends EntityBase {

    private List<EntityComputer> computerNodeList;

    public EntityValueNode() {
        super(NodeTypeEnum.变量);
        computerNodeList = new ArrayList<>();
    }

    public void addComputer(QlValueTypeEnum qlValueType, String value) {
        EntityComputer computer = new EntityComputer();
        computer.setValueType(qlValueType);
        computer.setValue(value);
        computerNodeList.add(computer);
    }

    public void addComputer(QlValueTypeEnum qlValueType, ComputerTypeEnum computerType, String value) {
        EntityComputer computer = new EntityComputer();
        computer.setValueType(qlValueType);
        computer.setComputerType(computerType);
        computer.setValue(value);
        computerNodeList.add(computer);
    }

    public void addComputer(QlValueTypeEnum qlValueType, ComputerTypeEnum computerType) {
        EntityComputer computer = new EntityComputer();
        computer.setValueType(qlValueType);
        computer.setComputerType(computerType);
        computerNodeList.add(computer);
    }

    public void addComputer(QlValueTypeEnum qlValueType, CompareTypeEnum compareType) {
        EntityComputer computer = new EntityComputer();
        computer.setValueType(qlValueType);
        computer.setCompareType(compareType);
        computerNodeList.add(computer);
    }

    public EntityValueNode addComputerInput(String value) {
        addComputer(QlValueTypeEnum.输入值, value);
        return this;
    }

    public EntityValueNode addChoiceGlobal(String globalId) {
        addComputer(QlValueTypeEnum.选择常量, globalId);
        return this;
    }

    public EntityValueNode addChoiceParam(String paramId) {
        addComputer(QlValueTypeEnum.选择输入参数, paramId);
        return this;
    }

    public EntityValueNode addComputer(ComputerTypeEnum computerType) {
        addComputer(QlValueTypeEnum.操作符, computerType);
        return this;
    }

    public EntityValueNode addCompare(CompareTypeEnum compareType) {
        addComputer(QlValueTypeEnum.比较符, compareType);
        return this;
    }

    public FlowLogicBuilder then() {
        FlowLogicBuilder flowLogicBuilder = new FlowLogicBuilder();
        return flowLogicBuilder;
    }
}
